---
title: Set claim context and retrieve
summary: Establishes the current claim context from a claim number or claim ID and retrieves claim data.
status: draft
owner: SAIF Claims BOF team
last_reviewed: 2026-08-21
library: SAIF.Application.Claim
reference_type: embedded
operation_id: OP-CLM-001
trigger: Caller (concrete claim-screen application manager) supplies a claim number or claim ID, typically from user input on a claim-search/claim-context web page.
---

# Set claim context and retrieve

Public method on `ClaimAppManager` that establishes the current claim context and triggers retrieval and security enforcement.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-CLM-001 |
| **Trigger** | Caller supplies `inClaimNumber As String` or `inClaimID As Decimal`. |
| **Inputs** | `inClaimNumber As String` or `inClaimID As Decimal` |
| **Outputs** | None (side effect — updates `Context`, `ClaimData`, `Message`, and security-derived state) |
| **Primary components** | `ClaimAppManager.SetClaimContext` |
| **Entry point** | `SAIF.Application.Claim\ClaimAppManager.vb` |

## Steps

1. Validate the input is non-trivial (string overload): checks `inClaimNumber.Trim.Length > 0` and that it is not the literal menu-context label ("claim #") per [BR-CLM-006](../business-rules.md#br-clm-006-blank-placeholder-claim-number-rejected).
   - On failure: `ClaimData` is cleared, `MarkContextNotSet()` is called, and `Message = ClaimAppConstants.PLEASEENTERCLAIM` is shown.
2. If valid, construct a new `ClaimContext` (`New(inClaimNumber)` or `New(inClaimID, 0)`) and call `ChangeContext()`.
3. `ChangeContext()` calls `OnContextChanged()`.
   - `OnContextChanged()` sets `Message = ClaimAppConstants.CLAIMNOTFOUND` per [BR-CLM-007](../business-rules.md#br-clm-007-claim-not-found-messaging), calls `GetClaimData()`, and if the resulting `ClaimData.IsValid`, clears `Message` and calls `MarkContextSet()`.
   - `GetClaimData()` reads `clsClaimData.GetData(DPI, Context.ClaimID)` or `clsClaimData.GetData(DPI, Context.ClaimNumber)` depending on which context value is set — a Retrieve call into the externally-packaged `SAIF.Business` claim business object (SQL ID and table not traceable from this library; owned by `SAIF.Business`, out of scope)**.
4. Only if `ContextSet` is true, `ChangeContext()` calls `OnCheckSecurity()`.
   - See [Security enforcement](security-enforcement.md), which enforces [BR-CLM-001](../business-rules.md#br-clm-001-conflict-claim-access-restriction) through [BR-CLM-005](../business-rules.md#br-clm-005-default-view-only-access-on-context-change).
5. `ChangeContext()` then calls `OnRetrieve()` — implemented by the concrete subclass outside this library; retrieval behavior beyond this point is subclass-specific and not traceable from this library's source**.
   - **Tech debt**: `SetClaimContext(inClaimID As Decimal)` (the decimal overload) only calls `MarkContextSet()` directly and does **not** call `ChangeContext()`/`OnCheckSecurity()`/`OnRetrieve()` — an asymmetry versus the string overload per [BR-CLM-006](../business-rules.md#br-clm-006-blank-placeholder-claim-number-rejected) that may be an intentional lightweight ID-only context set or an inconsistency**.

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start([SetClaimContext called]) --> Guard{Input valid?}
	Guard -->|No| Invalid([ClaimData cleared<br>MarkContextNotSet<br>Message: PLEASEENTERCLAIM])
	Guard -->|Yes| Change[ChangeContext]
	Change --> OCC[OnContextChanged:<br>GetClaimData]
	OCC --> Valid{ClaimData.IsValid?}
	Valid -->|No| NotFound([Message: CLAIMNOTFOUND])
	Valid -->|Yes| Set[MarkContextSet]
	Set --> Security[OnCheckSecurity]
	Security --> Retrieve[OnRetrieve<br>subclass-implemented]
```

## Failure and edge-case behavior

- Blank/placeholder claim number: rejected, see [BR-CLM-006](../business-rules.md#br-clm-006-blank-placeholder-claim-number-rejected).
- Claim not found after retrieval: reported, see [BR-CLM-007](../business-rules.md#br-clm-007-claim-not-found-messaging).
- Decimal-overload asymmetry (`SetClaimContext(inClaimID)` skips `ChangeContext`) — see step 5 above.

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)

> **Note:** Statements marked with `**` could not be confirmed; treat
> as unknown until verified.

## Sources
- `SAIF.Application.Claim\ClaimAppManager.vb`
- `SAIF.Application.Claim\ClaimAppConstants.vb`
